import request from "@/utils/request";
import type { pointRelation, questionForm } from "./type";

// 获取所有知识点
export const getPoint = () => {
  return request.get("/point/get");
};
export const getTag = () => {
  return request.get("/point/getTag");
};
// 知识点对应的习题
export const getQuestionByPoint = (point_id: number) => {
  return request.get(`${"/point"}/${point_id}`);
};
// 所有习题
export const getAllQuestions = () => {
  return request.get("/point/allQuestions");
};
// /relation/{pointId}
export const getRelation = (pointId: number) => {
  return request.get(`${"/point/relation"}/${pointId}`);
};
// 新建知识点
export const addPoint = (point: any) => {
  const param = new URLSearchParams();
  for (let key in point) {
    param.append(key, point[key]);
  }
  return request.post("/point/createPoint", param);
};
// 新建习题
export const addQuestion = (question: questionForm) => {
  return request.post("/point/createQuestion", question);
};
// 新建关联关系
export const addRelation = (pointRelation: pointRelation) => {
  return request.post("/point/createPointRelation", pointRelation);
};
// 修改关联强度
export const updateCorrelationStrength = (relations: pointRelation[]) => {
  return request.put("/point/updateCorrelationStrength", relations);
};
// 查询标签对应知识点
export const getPointByTag = (tagId: number) => {
  return request.get(`${"/point/getPointByTag"}/${tagId}`);
};